<template>
  <router-view></router-view>
</template>
<script setup>
  import request from '@/utils/request.ts'
  import store from '@/store'
  import { ref ,watch} from 'vue'
  import { useRoute,useRouter } from 'vue-router'
  const handleLogin=async ()=>{
    let result=await request.get('/user/login')
    const data=result.data
    console.log(data)
    if (data.code == 200){
        const token=data.data
        store.commit('SET_TOKEN',token)
    }else{
      alert('登录出错!')
    }
  }
  const handleUserList=async ()=>{
    let result=await request.get('/user/list')
    const data=result.data
    if (data.code==200){
      const userList=data.data
      console.log(userList)

    }
  }


  const route=useRoute();
  const whitePath=['/login','/']
  watch(route,(to,from)=>{

    console.log("to.name",to.name)
    console.log("to.path",to.path)
    if (whitePath.indexOf(to.path)===-1) {
      console.log("to.path="+to.path)
      let obj = {
        name: to.name,
        path: to.path
      }
      store.commit("ADD_TABS", obj)
    }
  },{deep:true,immediate:true})

</script>
<style lang="scss">
  html,body,#app{
    height: 100%;
  }
  .app-container {
    padding: 20px;
  }
</style>
